package com.wn.alibaba.cloud.sentinel.controller;

import com.wn.cloud.common.constant.ResponseEnum;
import com.wn.cloud.common.exception.GlobalException;
import com.wn.cloud.common.response.DataResult;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @FileName: ConsumerController
 * @Description: TODO
 * @Author: MaWenHao
 * @Created: 2020/4/11 - 22:53
 * @Version: V1.0
 * @Company: 东方微银科技（北京）有限公司
 */
@RestController
@RequestMapping("/provider")
public class ProviderController {

    @Value("${server.port}")
    private String serverPort;

    @GetMapping("/{id}")
    public DataResult<Object> getData1(@PathVariable("id") long id) {
        if (id < 0) {
            throw new GlobalException(ResponseEnum.ID_NOT_NEGATIVE);
        }
        if (id == 0) {
            throw new GlobalException(ResponseEnum.UNKNOWN_EXCEPTION);
        }
        return DataResult.genDataResult(ResponseEnum.SUCCESS, serverPort + ":  " + id);
    }
}
